import Vue from "vue";
import Router from 'vue-router'
import indexPage from "@/components/indexPage";
import NotFound from "@/components/common/NotFound";

Vue.use(Router)

const router = new Router({
    routes: [
        {
            path: '/',
            name: 'index',
            component: indexPage,
            meta: {
                display_name: "首页"
            }
        }, {
            path: '*',
            name: 'not found',
            component: NotFound,
            meta: {
                display_name: "404"
            }
        }
    ]
})

// 在路由跳转之前
router.beforeEach(function (to, from, next) {
    // 执行路由前的权限校验
    if (to.path === '/500')
        next('/404')
    else next()
});

// 在跳转路由之后
// router.afterEach(function (to, from) {
//     // 比如可以加载一些全局的数据，如通知
// })

export default router
